***************************************************************************
* Title:    Revealing Issue Salience via Costly Protest: 	 			  
* 			 How Legislative Behavior following Protest	 			        					   
*				Advantages Low-Resource Groups     	 			          
* Author: 	LaGina Gause (lgause@ucsd.edu) 							      
* Date: 06/27/2020                                                        
* Software: Stata 14.2                                                    
***************************************************************************



// set directory

/* 
Required Dataset

bjps_costlyprotest_replication_data.csv
*/

set more off
set matsize 800

*************************************
******** Summary Statistics *********
*************************************

*ssc inst unique

tab protest majortopic 

tab support if support!=.

unique eventid 

unique eventid if support!=.

display 503/612 

unique rccount cnrptyy if support!=.

*****************************
*****************************
****** Label Variables ******
*****************************
*****************************

label define ethnic 1 "Nonwhite Participants" 0 "White Participants"
label values nonwhite ethnic

label define orgtype 1 "No Organized Interest Group" 0 "Organized Interest Group"
label values noorgig orgtype

label define econ 1 "Low-Income Participants" 0 "Higher Income Participants" 
label values poorh econ



label define ethnicc 2 "Nonwhite Participants" 1 "White Participants" 0 "No Protest"
label values nonwhitec ethnicc

label define orgtypec 2 "No Organized Interest Group" 1 "Organized Interest Group" 0 "No Protest"
label values noorgigc orgtypec

label define econc 2 "Low-Income Participants" 1 "Higher Income Participants" 0 "No Protest"
label values poorhc econc

label define protestv 1 "Protest" 0 "No Protest"
label values protest protestv

label variable protest "Protest"
label variable educ "Education"
label variable dem "Democratic Representative" 
label variable lengthserve "Length of Service" 
label variable votemargin "Margin of Victory" 
label variable blkrep "Black Representative" 
label variable hisprep "Latino Representative" 
label variable womanrep "Female Representative"


label define sizes 1 "Small" 2 "Group" 3 "Large" 4 "Hundreds" 5 "Thousands" 6 "Tens of Thousands"
label values osize sizes

label define articles 1 "Multiple Articles" 0 "One Article"
label values stories0 articles

label define contentious 1 "Disruptive" 0 "Not Disruptive"
label values disruptive0 contentious


***********************************************
***********************************************
******* Table 1: Means and Differences ********
***********************************************
***********************************************

preserve
keep if lib==1 

mat T = J(14,4,.)

ttest supportall2, by(protest) 
mat T[1,1] = r(N_1)
mat T[2,1] = r(N_2)
mat T[1,2] = r(mu_1)
mat T[2,2] = r(mu_2)
mat T[2,3] = r(mu_1) - r(mu_2)
mat T[2,4] = r(p)

ttest supportall2 if poorhc==0|poorhc==1, by(poorhc)
mat T[3,1] = r(N_1)
mat T[4,1] = r(N_2)
mat T[3,2] = r(mu_1)
mat T[4,2] = r(mu_2)
mat T[4,3] = r(mu_1) - r(mu_2)
mat T[4,4] = r(p)

ttest supportall2 if poorhc==1|poorhc==2, by(poorhc)
mat T[5,1] = r(N_1)
mat T[6,1] = r(N_2)
mat T[5,2] = r(mu_1)
mat T[6,2] = r(mu_2)
mat T[6,3] = r(mu_1) - r(mu_2)
mat T[6,4] = r(p)

ttest supportall2 if nonwhitec==0|nonwhitec==1, by(nonwhitec)
mat T[7,1] = r(N_1)
mat T[8,1] = r(N_2)
mat T[7,2] = r(mu_1)
mat T[8,2] = r(mu_2)
mat T[8,3] = r(mu_1) - r(mu_2)
mat T[8,4] = r(p)

ttest supportall2 if nonwhitec==1|nonwhitec==2, by(nonwhitec)
mat T[9,1] = r(N_1)
mat T[10,1] = r(N_2)
mat T[9,2] = r(mu_1)
mat T[10,2] = r(mu_2)
mat T[10,3] = r(mu_1) - r(mu_2)
mat T[10,4] = r(p)

ttest supportall2 if noorgigc==0|noorgigc==1, by(noorgigc)
mat T[11,1] = r(N_1)
mat T[12,1] = r(N_2)
mat T[11,2] = r(mu_1)
mat T[12,2] = r(mu_2)
mat T[12,3] = r(mu_1) - r(mu_2)
mat T[12,4] = r(p)

ttest supportall2 if noorgigc==1|noorgigc==2, by(noorgigc)
mat T[13,1] = r(N_1)
mat T[14,1] = r(N_2)
mat T[13,2] = r(mu_1)
mat T[14,2] = r(mu_2)
mat T[14,3] = r(mu_1) - r(mu_2)
mat T[14,4] = r(p)

frmttable using example.tex,  statmat(T)  sdec(0,4)  replace ///
	ctitle("", Observations, Mean Support, Difference, "(p-value)") ///
	rtitle("No Protest"\"Protest"\ "No Protest"\ "Higher Income Participants" \"Higher Income Participants"\ "Low-Income Participants" ///
	\"No Protest" \ "White Participants" \ "White Participants" \ "Non-White Participants" \ "No Protest" \ "Organized Interest Group" ///
	\"Organized Interest Group" \ "No Organized Interest Group")
restore


**************************************
**************************************
***** Model Specification Checks *****
**************************************
**************************************
encode statecd, gen(statecd1)

**** Fixed Effects Model ****
**** Fixed Effects Model ****
**** Fixed Effects Model ****
eststo pfe2, title("Model I"): logit supportall2 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy i.statecd1 if lib==1


**** Random Effects models ****
**** Random Effects models ****
**** Random Effects models ****
eststo pre2, title("Model I"):  melogit supportall2 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy  if lib==1|| statecd:, nolog 


**** Pooled Regression Models ****
**** Pooled Regression Models ****
**** Pooled Regression Models ****

eststo pp2, title("Model I"):  logit supportall2 i.poorhc educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1,  nolog


hausman pfe2 pre2, alleqs


******* WU (1973) Variable Addition Test *********
******* WU (1973) Variable Addition Test *********
******* WU (1973) Variable Addition Test *********

**** Gather means for fixed effects variables (vary across time)
egen educm = mean(educ), by(statecd1)
egen lenm = mean(lengthserve), by(statecd1)
egen margm = mean(votemargin), by(statecd1)

melogit supportall2 poorhc nonwhitec noorgigc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy educm lenm margm if lib==1|| statecd:, nolog 

test  educm lenm margm 

reg supportall2 i.poorhc educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy  i.statecd1 if lib==1 




**************************************
**************************************
****** Table 2 (Logit with RE) *******
**************************************
**************************************

eststo prore2lib, title("Model I"):  melogit supportall2 i.protest  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy  if lib==1|| statecd:, nolog 
eststo pro2rediff: margins, dydx(protest) vsquish atmeans post

**** Figure 2, Model I ****
marginsplot, xlabel(1 "Protest" ) graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(0(.2)1)  ///
ytitle("Difference in Probability of Support") title ("Model I", color(black)) xtitle (" ")



eststo pre2lib, title("Model II"):  melogit supportall2 i.poorhc educ dem lengthserve votemargin blkrep hisprep womanrep i.cnrptyy  if lib==1|| statecd:, nolog 
eststo p2rediff: margins, dydx(poorhc) vsquish atmeans post
test 1.poorhc - 2.poorhc = 0

**** Figure 2, Model II ****
est restore p2rediff
marginsplot, xlabel(1 "Higher Income Participants" 2 "Low-Income Participants") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(0(.2)1)  ///
ytitle("Difference in Probability of Support") title ("Model II", color(black)) xtitle (" ")


eststo nre2lib, title("Model III"):  melogit supportall2 i.nonwhitec educ dem lengthserve votemargin blkrep hisprep womanrep i.cnrptyy  if lib==1|| statecd:, nolog 
eststo n2rediff: margins, dydx(nonwhite) vsquish atmeans post 
test 1.nonwhitec - 2.nonwhitec = 0

**** Figure 2, Model III ****
est restore n2rediff
marginsplot, xlabel(1 "White Participants" 2 "Nonwhite Participants") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(0(.2)1)  ///
ytitle("Difference in Probability of Support") title ("Model III", color(black)) xtitle (" ")


eststo nigre2lib, title("Model IV"):  melogit supportall2 i.noorgigc educ dem lengthserve votemargin blkrep hisprep womanrep i.cnrptyy  if lib==1|| statecd:, nolog 
eststo ig2rediff: margins, dydx(noorgig) vsquish atmeans post
test 1.noorgigc - 2.noorgigc = 0

**** Figure 2, Model IV ****
est restore ig2rediff
marginsplot, xlabel(1 "Organized Interest Group" 2 "No Organized Interest Group") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(0(.2)1)  ///
ytitle("Difference in Probability of Support") title ("Model IV", color(black)) xtitle (" ")




**** Table 2**** 
**** Table 2**** 
**** Table 2**** 
**** Table 2**** 

esttab prore2lib pre2lib nre2lib nigre2lib using example.tex, booktabs scalars("N_g Groups" "ll Log likelihood" "lrtest_chi2 LR test Chi$^2$") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Legislative Support and Constituency Preferences  (Liberal Only)  \label{tabmain}) ///
		 mtitles("Model I" "Model II" "Model III" "Model IV") ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 addnotes("Coefficients are Log Odds. All independent variables are coded 0 to 1.") ///
		 order(1.protest 1.poorhc 2.poorhc 1.nonwhitec 2.nonwhitec 1.noorgigc 2.noorgigc educ dem lengthserve votemargin blkrep hisprep womanrep) ///
		 star(* 0.10 ** 0.05 *** 0.01) nobaselevels nodepvars


****************************
****************************
****** Placebo Tests *******
****************************
****************************

*** Min RCVs ***
*** Min RCVs ***
*** Min RCVs ***

eststo promin2, title("Model I"): mixed wnommin10to1 protest   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
eststo pmin2, title("Model II"): mixed wnommin10to1 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
test 1.poorhc-2.poorhc=0

eststo nmin2, title("Model III"): mixed wnommin10to1 i.nonwhitec  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
test 1.nonwhitec-2.nonwhitec=0

eststo nigmin2, title("Model IV"): mixed wnommin10to1 i.noorgigc   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog  
test 1.noorgigc-2.noorgigc=0

*** Appendix E, Table 5 ****
esttab promin2 pmin2 nmin2 nigmin2 using example.tex, booktabs scalars("N_g Groups" "ll Log likelihood" "lrtest_chi2 LR test Chi$^2$") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars transform(ln*: exp(2*@) 2*exp(2*@)) ///
		 title(General Legislative Support (via minority w-nominate scores) and Constituent Preferences  (Liberal Only) \label{tabplacebomin}) ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 addnotes("Coefficients are Log Odds. All independent variables are coded 0 to 1.") ///
		 order(protest 1.poorhc 2.poorhc 1.nonwhitec 2.nonwhitec 1.noorgigc 2.noorgigc educ dem lengthserve votemargin blkrep hisprep womanrep) ///
		 star(* 0.10 ** 0.05 *** 0.01) nobaselevels nodepvars

*** Figure 3, Minority Roll Call Votes, Model I ***
coefplot promin2,  keep(protest)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "Protest")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model I", color(black)) xtitle (" ") bcolor(gray)

*** Figure 3, Minority Roll Call Votes, Model II ***
coefplot pmin2,  keep(1.poorhc 2.poorhc)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "Higher Income Participants" 2 "Low-Income Participants")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model II", color(black)) xtitle (" ") bcolor(gray)

*** Figure 3, Minority Roll Call Votes, Model III ***
coefplot nmin2,  keep(1.nonwhitec 2.nonwhitec)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "White Participants" 2 "Nonwhite Participants")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model III", color(black)) xtitle (" ") bcolor(gray)

*** Figure 3, Minority Roll Call Votes, Model IV ***
coefplot nigmin2,  keep(1.noorgigc 2.noorgigc)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "Organized Interest Group" 2 "No Organized Interest Group")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model IV", color(black)) xtitle (" ") bcolor(gray)



**** All RCVs ****
**** All RCVs ****
**** All RCVs ****

eststo pronom2, title("Model I"): mixed wnom10to1 protest   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
eststo pnom2, title("Model II"): mixed wnom10to1 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
test 1.poorhc-2.poorhc=0
eststo nnom2, title("Model III"): mixed wnom10to1 i.nonwhitec  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
test 1.nonwhitec-2.nonwhitec=0
eststo nignom2, title("Model IV"): mixed wnom10to1 i.noorgigc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
 test 1.noorgigc-2.noorgigc=0

*** Appendix E, Table 6 ****
esttab pronom2 pnom2 nnom2 nignom2 using example.tex, booktabs scalars("N_g Groups" "ll Log likelihood" "lrtest_chi2 LR test Chi$^2$") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars transform(ln*: exp(2*@) 2*exp(2*@)) ///
		 title(General Legislative Support (via all w-nominate scores) and Constituent Preferences  (Liberal Only) \label{tabplacebo}) ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 addnotes("Coefficients are Log Odds. All independent variables are coded 0 to 1.") ///
		 order(protest 1.poorhc 2.poorhc 1.nonwhitec 2.nonwhitec 1.noorgigc 2.noorgigc educ dem lengthserve votemargin blkrep hisprep womanrep) ///
		 star(* 0.10 ** 0.05 *** 0.01) nobaselevels nodepvars

*** Figure 3, All Roll Call Votes, Model I ***
coefplot pronom2,  keep(protest)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "Protest")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model I", color(black)) xtitle (" ") bcolor(gray)

*** Figure 3, All Roll Call Votes, Model II ***
coefplot pnom2,  keep(1.poorhc 2.poorhc)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "Higher Income Participants" 2 "Low-Income Participants")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model II", color(black)) xtitle (" ") bcolor(gray)

*** Figure 3, All Roll Call Votes, Model III ***
coefplot nnom2,  keep(1.nonwhitec 2.nonwhitec)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "White Participants" 2 "Nonwhite Participants")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model III", color(black)) xtitle (" ") bcolor(gray)

*** Figure 3, All Roll Call Votes, Model IV ***
coefplot nignom2,  keep(1.noorgigc 2.noorgigc)  vertical recast(bar)  /// 
		ciopts(lcolor(black) recast(rcap)) citop yline(0, lcolor(black) lpattern(dash)) ///
		nokey ylabel(-.04(.01).06) xlabel(1 "Organized Interest Group" 2 "No Organized Interest Group")  graphregion(fcolor(white) lcolor(white)) ///
		title ("Model IV", color(black)) xtitle (" ") bcolor(gray)


*******************************************
*******************************************
******** Alternative Explanations *********
*******************************************
*******************************************


***** Size *****
***** Size *****
***** Size *****

ttest osize if support!=., by(poorh)
eststo psize:  melogit supportall2 poorh##osize   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(poorh) at(osize=(1(1)6)) vsquish atmeans 

*** Figure 4A ***
marginsplot, x(osize) xlabel(1 "0-9" 2 "10-49" 3 "50-99" 4"100-999" 5 "1,000-9,999" 6 "10,000+") graphregion(fcolor(white)) legend(off)  ///
plotopts(mcolor(black) msize(small) lcolor(black) ) ///
ciopts(lcolor(black)) xsize(7) ylabel(-.4(.2).6) ///
title("(A) Resources (Low-Income vs Higher Income)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Number of Persons at Event") yline(0, lcolor(g16))

ttest osize if support!=., by(nonwhite)
eststo nwsize:  melogit supportall2 nonwhite##osize   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(nonwhite) at(osize=(1(1)6)) vsquish atmeans 

*** Figure 4B ***
marginsplot, x(osize) xlabel(1 "0-9" 2 "10-49" 3 "50-99" 4"100-999" 5 "1,000-9,999" 6 "10,000+") graphregion(fcolor(white)) legend(off)  ///
plotopts(mcolor(black) msize(small) lcolor(black) ) ///
ciopts(lcolor(black)) xsize(7) ylabel(-.4(.2).6) ///
title("(B) Resources (Nonwhite vs White)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Number of Persons at Event") yline(0, lcolor(g16))

ttest osize if support!=., by(noorgig)
eststo igsize: melogit supportall2 noorgig##osize   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(noorgig) at(osize=(1(1)6)) vsquish atmeans 

*** Figure 4C ***
marginsplot, x(osize) xlabel(1 "0-9" 2 "10-49" 3 "50-99" 4"100-999" 5 "1,000-9,999" 6 "10,000+") graphregion(fcolor(white)) legend(off)  ///
plotopts(mcolor(black) msize(small) lcolor(black) ) ///
ciopts(lcolor(black)) xsize(7) ylabel(-.4(.2).6) ///
title("(C) Organizational Resources", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Number of Persons at Event") yline(0, lcolor(g16))

*** Appendix E, Table 7 ****
esttab psize nwsize igsize using example.tex, booktabs scalars("ll Log likelihood") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Resources, Salience (Size) and Legislative Support \label{tabfigsize}) ///
		 mtitles("Model A" "Model B" "Model C" "Model D") ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 drop(0.poorh 0.nonwhite 0.noorgig 0.poorh*osize 0.nonwhite*osize 0.noorgig*osize 1.poorh*1.osize 1.nonwhite*1.osize 1.noorgig*1.osize 1.osize educ  dem  lengthserve  votemargin blkrep hisprep womanrep) ///
		 order(1.poorh 1.nonwhite 1.noorgig 2.osize 3.osize 4.osize 5.osize 6.osize 1.poorh*osize 1.nonwhite*osize 1.noorgig*osize) ///
		 addnotes("Coefficients are Log Odds. The dependent variable, legislative support, is binary taking on a value of 0 or 1. " "All independent variables are coded 0 to 1." "Estimates informing Figure 2.")

		 
***** Protest Frequency *****
***** Protest Frequency *****
***** Protest Frequency *****

by statecd cnrptyy rccount, sort: egen numprotest = count(protest) if protest==1 
replace numprotest=0 if protestincd==0

by statecd cnrptyy rccount, sort: egen numprotestpoor = count(protest) if protest==1 & poorh==1
by statecd cnrptyy rccount, sort: egen numprotestnp = count(protest) if protest==1 & poorh==0

gen numprotestp = .
replace numprotestp=numprotestpoor if poorh==1
replace numprotestp=numprotestnp if poorh==0
replace numprotestp=0 if protestincd==0

ttest numprotestp if support!=., by(poorh) 

label define freq 1 "1 Protest" 2 "2 Protests" 3 "3 Protests" 4 "4 Protests" 5 "5 Protests" 6 "6 Protests" 7 "7 Protests" 8 "8 Protests" 9 "9 Protests" 10 "10 Protests" 12 "12 Protests" 14 "14 Protests" 15 "15 Protests" 16 "16 Protests" 17 "17 Protests" 20 "20 Protests", modify
label values numprotestp freq

*** Figure 5A ***
eststo pfreq:  melogit supportall2 poorh##numprotestp   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(poorh) at(numprotestp=(1(1)8)) vsquish atmeans 
marginsplot, x(numprotestp) graphregion(fcolor(white)) legend(off)  ///
plotopts(mcolor(black) msize(small) lcolor(black) ) ///
ciopts(lcolor(black)) xsize(7) ylabel(-.6(.2).6) ///
title("(A) Resources (Low-Income vs Higher Income)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Number of Protests on Issue in District") yline(0, lcolor(g16))


by statecd cnrptyy rccount, sort: egen numprotestnonw = count(protest) if protest==1 & nonwhite==1
by statecd cnrptyy rccount, sort: egen numprotestwhite = count(protest) if protest==1 & nonwhite==0

gen numprotestnw = .
replace numprotestnw=numprotestnonw if nonwhite==1
replace numprotestnw=numprotestwhite if nonwhite==0
replace numprotestnw=0 if protestincd==0

label values numprotestnw freq

ttest numprotestnw if support!=., by(nonwhite)

eststo nwfreq: melogit supportall2 i.nonwhite##i.numprotestnw   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(nonwhite) at(numprotestnw=(1/8)) vsquish atmeans 

*** Figure 5B ***
marginsplot, x(numprotestnw) xtitle("Number of Protests on Issue in District") graphregion(fcolor(white)) legend(off)  ///
plotopts(mcolor(black) msize(small) lcolor(black) ) ///
ciopts(lcolor(black)) xsize(7) ylabel(-.6(.2).6) ///
title(" (B) Resources (Nonwhite vs White)", color(black))  ///
ytitle("Difference in Effect of Resources") yline(0, lcolor(g16)) 


by statecd cnrptyy rccount, sort: egen numprotestnoorg = count(protest) if protest==1 & noorgig==1
by statecd cnrptyy rccount, sort: egen numprotestig = count(protest) if protest==1 & noorgig==0

gen numprotestnoig = .
replace numprotestnoig=numprotestnoorg if noorgig==1
replace numprotestnoig=numprotestig if noorgig==0
replace numprotestnoig=0 if protestincd==0

label values numprotestnoig freq

ttest numprotestnoig if support!=., by(noorgig)

eststo igfreq:  melogit supportall2 i.noorgig##numprotestnoig  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(noorgig) at(numprotestnoig=(1/5) ) vsquish atmeans 

*** Figure 5C ***
marginsplot, x(numprotestnoig) graphregion(fcolor(white)) legend(off)  ///
plotopts(mcolor(black) msize(small) lcolor(black) ) ///
ciopts(lcolor(black)) xsize(7) ylabel(-.6(.2).6) ///
title("(C) Resources (No Interest Group vs Interest Group)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Number of Protests on Issue in District") yline(0, lcolor(g16))

*** Appendix E, Table 8 ****
esttab pfreq nwfreq igfreq using example.tex, booktabs scalars("ll Log likelihood") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Resources, Salience (Protest Frequency) and Legislative Support \label{tabfigfreq}) ///
		 mtitles("Model A" "Model B" "Model C" ) ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 drop(0.poorh 0.nonwhite 0.noorgig 0.poorh*numprotestp 0.nonwhite*numprotestnw 0.noorgig*numprotestnoig 1.poorh*1.numprotestp 1.nonwhite*1.numprotestnw 1.noorgig*1.numprotestnoig 1.numprotestp 1.numprotestnw 1.numprotestnoig educ  dem  lengthserve  votemargin blkrep hisprep womanrep) ///
		 order(1.poorh 1.nonwhite 1.noorgig 2.numprotestp 3.numprotestp 4.numprotestp 5.numprotestp 6.numprotestp 1.poorh*numprotestp 1.nonwhite*numprotestnw 1.noorgig*numprotestnoig) ///
		 addnotes("Coefficients are Log Odds. The dependent variable, legislative support, is binary taking on a value of 0 or 1. " "All independent variables are coded 0 to 1." "Estimates informing Figure 2.")

		 
		
	
******** Media Coverage *********
******** Media Coverage *********
******** Media Coverage *********

ttest stories0 if support!=., by(poorh)

eststo pstories:  melogit supportall2 i.poorh##i.stories0   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(poorh) over(stories0) vsquish atmeans 

*** Figure 6A ***
marginsplot, x(stories0) xlabel(0 "no" 1 "yes") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(-.6(.2).6) ///
title(" (A) Resources (Poor vs Nonpoor)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Multiple Newspaper Articles on Event") yline(0, lcolor(g8)) 
 

ttest stories0 if support!=., by(nonwhite)

eststo nwstories:  melogit supportall2 nonwhite##stories0   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(nonwhite) at(stories0=(0 1)) vsquish atmeans 

*** Figure 6B ***
marginsplot, x(stories0) xlabel(0 "no" 1 "yes") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(-.6(.2).6) ///
title("(B) Resources (Nonwhite vs White)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Multiple Newspaper Articles on Event") yline(0, lcolor(g8)) 


ttest stories0 if support!=., by(noorgig)

eststo igstories:  melogit supportall2 noorgig##stories0   educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(noorgig) at(stories0=(0 1)) vsquish atmeans 

*** Figure 6C ***
marginsplot, x(stories0) xlabel(0 "no" 1 "yes") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(-.6(.2).6) ///
title("(C) Organizational Resources", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Multiple Newspaper Articles on Event") yline(0, lcolor(g8))  

*** Appendix E, Table 9 ****
esttab pstories nwstories igstories using example.tex, booktabs scalars("ll Log likelihood") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Resources, Salience (Media Coverage) and Legislative Support \label{tabfigmed}) ///
		 mtitles("Model A" "Model B" "Model C" "Model D") ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 drop(0.poorh 0.nonwhite 0.noorgig 0.poorh*stories0 0.nonwhite*stories0 0.noorgig*stories0  1.poorh*0.stories0 1.nonwhite*0.stories0 1.noorgig*0.stories0 0.stories0 educ  dem  lengthserve  votemargin blkrep hisprep womanrep) ///
		 order(1.poorh 1.nonwhite 1.noorgig 1.stories0 1.poorh*stories0 1.nonwhite*stories0 1.noorgig*stories0) ///
		 addnotes("Coefficients are Log Odds. The dependent variable, legislative support, is binary taking on a value of 0 or 1. " "All independent variables are coded 0 to 1." "Estimates informing Figure 4.")


**** Disruptiveness ****
**** Disruptiveness ****
**** Disruptiveness ****


ttest disruptive0 if support!=., by(poorh)

eststo pdis:  melogit supportall2 poorh##disruptive0    educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(poorh) at(disruptive0=(0 1)) vsquish atmeans 

*** Figure 7A ***
marginsplot, x(disruptive0) xlabel(0 "no" 1 "yes") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(-.2(.1).6)  ///
title("(A) Resources (Poor vs Nonpoor)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Disruptive Event") yline(0, lcolor(g8))

ttest disruptive0 if support!=., by(nonwhite)

eststo nwdis:  melogit supportall2 nonwhite##disruptive0    educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(nonwhite) at(disruptive0=(0 1)) vsquish atmeans 

*** Figure 7B ***
marginsplot, x(disruptive0) xlabel(0 "no" 1 "yes") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(-.2(.1).6)  ///
title("(B) Resources (Nonwhite vs White)", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Disruptive Event") yline(0, lcolor(g8))

ttest disruptive0 if support!=., by(noorgig)

eststo igdis:  melogit supportall2 noorgig##disruptive0    educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if lib==1|| statecd:, nolog 
margins, dydx(noorgig) at(disruptive0=(0 1)) vsquish atmeans 

*** Figure 7C ***
marginsplot, x(disruptive0) xlabel(0 "no" 1 "yes") graphregion(fcolor(white)) legend(off)  ///
plotopts(color(gray) msize(small) lcolor(black) ) recast(bar) ///
ciopts(lcolor(black) lpattern(dash)) ylabel(-.2(.1).6)  ///
title("(C) Organizational Resources", color(black))  ///
ytitle("Difference in Effect of Resources") xtitle("Disruptive Event")

*** Appendix E, Table 10 ****
esttab pdis nwdis igdis using example.tex, booktabs scalars("ll Log likelihood") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Resources, Salience (Disruptiveness) and Legislative Support \label{tabfigdis}) ///
		 mtitles("Model A" "Model B" "Model C") ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 drop(0.poorh 0.nonwhite 0.noorgig 0.poorh*disruptive0 0.nonwhite*disruptive0 0.noorgig*disruptive0  1.poorh*0.disruptive0 1.nonwhite*0.disruptive0 1.noorgig*0.disruptive0 0.disruptive0 educ  dem  lengthserve  votemargin blkrep hisprep womanrep) ///
		 order(1.poorh 1.nonwhite 1.noorgig 1.disruptive0 1.poorh*disruptive0 1.nonwhite*disruptive0 1.noorgig*disruptive0) ///
		 addnotes("Coefficients are Log Odds. The dependent variable, legislative support, is binary taking on a value of 0 or 1. " "All independent variables are coded 0 to 1." "Estimates informing Figure 5.")


*************************************
*************************************
******** Robustness Checks  *********
*************************************
*************************************

****** LPM ******
****** LPM ******
****** LPM ******

eststo prolpm2: reg supportall2 protest  educ  dem  lengthserve  votemargin blkrep hisprep womanrep   if lib==1
eststo plpm2: reg supportall2 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep if lib==1
eststo nlpm2: reg supportall2 i.nonwhitec  educ  dem  lengthserve  votemargin blkrep hisprep womanrep  if lib==1
eststo niglpm2: reg supportall2 i.noorgigc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep if lib==1

*** Appendix D, Table 1 ****
esttab prolpm2 plpm2 nlpm2 niglpm2 using example.tex, booktabs label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Linear Probability Model (Liberal Claims)  \label{tabreslpm2}) ///
		 mtitles("Model I" "Model II" "Model III" "Model IV") ///
		 order(protest 1.poorhc 2.poorhc 1.nonwhitec 2.nonwhitec 1.noorgigc 2.noorgigc educ  dem  lengthserve  votemargin blkrep hisprep womanrep) ///
		 addnotes("The dependent variable, legislative support, is binary taking on a value of 0 or 1. All independent variables are coded 0 to 1, except for the protesters' resource variables.") ///
		 star(* 0.10 ** 0.05 *** 0.01) nobaselevels nodepvars


****** (LPM with  FE) *******
****** (LPM with  FE) *******
****** (LPM with  FE) *******

eststo prolpm2fe: reg supportall2 protest  educ  dem  lengthserve  votemargin blkrep hisprep womanrep   i.statecd1 i.cnrptyy  if lib==1
eststo plpm2fe: reg supportall2 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep   i.statecd1 i.cnrptyy  if lib==1
eststo nlpm2fe: reg supportall2 i.nonwhitec  educ  dem  lengthserve  votemargin blkrep hisprep womanrep   i.statecd1 i.cnrptyy  if lib==1
eststo niglpm2fe: reg supportall2 i.noorgigc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep   i.statecd1 i.cnrptyy  if lib==1

*** Appendix D, Table 2 ****
esttab prolpm2fe plpm2fe nlpm2fe niglpm2fe using example.tex, booktabs label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Linear Probability Model with Fixed Effects (Liberal Claims)  \label{tabreslpmfe2}) ///
		 mtitles("Model I" "Model II" "Model III" "Model IV" ) ///
		 indicate("Congressional District Dummies = *statecd1" "Congress Dummies = *cnrptyy") ///
		 order(protest 1.poorhc 2.poorhc 1.nonwhitec 2.nonwhitec 1.noorgigc 2.noorgigc educ  dem  lengthserve  votemargin blkrep hisprep womanrep ) ///
		 addnotes("The dependent variable, legislative support, is binary taking on a value of 0 or 1. All independent variables are coded 0 to 1, except for the protesters' resource variables.") ///
		 star(* 0.10 ** 0.05 *** 0.01) nobaselevels nodepvars



****** (Logistic regressions with FE) *******
****** (Logistic regressions with FE) *******
****** (Logistic regressions with FE) *******

eststo profe2lib: logit supportall2 protest  educ  dem  lengthserve  votemargin blkrep hisprep womanrep  i.statecd1 i.cnrptyy  if lib==1
eststo pfe2lib: logit supportall2 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep   i.statecd1 i.cnrptyy  if lib==1
eststo nfe2lib: logit supportall2 i.nonwhitec  educ  dem  lengthserve  votemargin blkrep hisprep womanrep  i.statecd1 i.cnrptyy  if lib==1
eststo nigfe2lib: logit supportall2 i.noorgigc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep  i.statecd1 i.cnrptyy  if lib==1

*** Appendix D, Table 3 ****
esttab profe2lib pfe2lib nfe2lib nigfe2lib using example.tex, booktabs scalars("ll Log likelihood") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Logistic Regressions with Fixed Effects (Liberal Claims) \label{tabresfe2}) ///
		 mtitles("Model I" "Model II" "Model III" "Model IV") ///
		 indicate("Congressional District Dummies = *statecd1" "Congress Dummies = *cnrptyy") ///
		 order(protest 1.poorhc 2.poorhc 1.nonwhitec 2.nonwhitec 1.noorgigc 2.noorgigc educ  dem  lengthserve  votemargin blkrep hisprep womanrep ) ///
		 addnotes("Coefficients are Log Odds. The dependent variable, legislative support, is binary taking on a value of 0 or 1. All independent variables are coded 0 to 1.") ///
		 star(* 0.10 ** 0.05 *** 0.01) nobaselevels


****** Logit with RE, conservative claims *******
****** Logit with RE, conservative claims *******
****** Logit with RE, conservative claims *******

eststo prore2cons, title("Model I"):  melogit supportall2 protest  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if cons==1|| statecd:, nolog 
eststo pre2cons, title("Model II"):  melogit supportall2 i.poorhc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if  cons==1|| statecd:, nolog 
eststo nre2cons, title("Model III"):  melogit supportall2 i.nonwhitec educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if  cons==1|| statecd:, nolog 
eststo nigre2cons, title("Model IV"):  melogit supportall2 i.noorgigc  educ  dem  lengthserve  votemargin blkrep hisprep womanrep i.cnrptyy if  cons==1|| statecd:, nolog 

*** Appendix D, Table 4 ****
esttab prore2cons pre2cons nre2cons nigre2cons  using example.tex, booktabs scalars("N_g Groups" "ll Log likelihood" "lrtest_chi2 LR test Chi$^2$") label se replace  ///
		 alignment(D{.}{.}{-1}) page(dcolumn) nonumber mtitle nodepvars ///
		 title(Mixed Effects Logistic Regression (Conservative Claims)  \label{tabcons2}) ///
		 mtitles("Model I" "Model II" "Model III" "Model IV") ///
		 indicate("Congress Year Dummies = *cnrptyy" ) ///
		 addnotes("Coefficients are Log Odds. All independent variables are coded 0 to 1.") ///
		 order(protest 1.poorhc 2.poorhc 1.nonwhitec 2.nonwhitec 1.noorgigc 2.noorgigc educ dem lengthserve votemargin blkrep hisprep womanrep) ///
		 star(* 0.10 ** 0.05 *** 0.01) nobaselevels nodepvars


log close
